Plain text file implementation for UTCP
The Text provider enables UTCP to interact with tools defined in local text files, which is useful for file-based tools, development environments, and creating aggregated collections of tools from different providers without requiring a server component.
Text providers are configured using the following JSON structure:
{ "name": "local_tools", "provider_type": "text", "file_path": "/path/to/tools.json", "encoding": "utf-8", "watch_file": true, "cache_duration": 300000, "auto_reload": true }
Field | Required | Description |
---|---|---|
name |
Yes | Unique identifier for the provider |
provider_type |
Yes | Must be set to "text" |
file_path |
Yes | Path to the file containing tool definitions (supports absolute and relative paths) |
encoding |
No | File encoding (default: "utf-8" ) |
watch_file |
No | Whether to watch the file for changes (default: false ) |
cache_duration |
No | Cache duration in milliseconds (default: 300000 ) |
auto_reload |
No | Whether to automatically reload when file changes (default: true ) |
The Text provider can be used in several scenarios:
Tools that operate on files or require local file system access. The tool definitions include information about how to delegate calls to local processes or file operations.
Collecting tools from multiple providers into a single configuration file for easier management and deployment. Each tool can reference its own provider configuration.
Creating mock tools for development and testing purposes without requiring actual service endpoints. Useful for prototyping and local development.
Managing tool definitions as code, allowing version control and deployment automation of tool configurations across environments.
The text file should contain either:
A complete UTCP manual containing version and tools array:
{ "version": "1.0", "tools": [ { "name": "tool_name", "description": "Tool description", "inputs": { ... }, "outputs": { ... } } ] }
A simple array of tool definitions:
[ { "name": "tool_name", "description": "Tool description", "inputs": { ... }, "outputs": { ... } } ]
{ "name": "local_file_tools", "provider_type": "text", "file_path": "/etc/utcp/system_tools.json", "watch_file": true, "auto_reload": true }
Content of system_tools.json
:
{ "version": "1.0", "tools": [ { "name": "read_system_stats", "description": "Read system statistics", "inputs": { "type": "object", "properties": { "stat_type": { "type": "string", "enum": ["cpu", "memory", "disk"], "description": "Type of statistics to read" } }, "required": ["stat_type"] }, "outputs": { "type": "object", "properties": { "usage_percent": { "type": "number", "description": "Usage percentage" }, "details": { "type": "object", "description": "Detailed statistics" } } }, "provider": { "name": "system", "provider_type": "cli", "command_name": "system-stats", "param_style": "named", "output_format": "json" } } ] }
{ "name": "tool_collection", "provider_type": "text", "file_path": "./config/aggregated_tools.json", "cache_duration": 600000 }
Content of aggregated_tools.json
:
{ "version": "1.0", "tools": [ { "name": "weather", "description": "Get weather information", "inputs": { "type": "object", "properties": { "location": { "type": "string", "description": "Location to get weather for" } }, "required": ["location"] }, "outputs": { "type": "object", "properties": { "temperature": { "type": "number" }, "conditions": { "type": "string" } } }, "provider": { "name": "weather_api", "provider_type": "http", "url": "https://api.weather.com/current", "http_method": "GET", "auth": { "auth_type": "api_key", "api_key": "YOUR_WEATHER_KEY", "var_name": "X-API-Key" } } }, { "name": "translate", "description": "Translate text between languages", "inputs": { "type": "object", "properties": { "text": { "type": "string" }, "from_lang": { "type": "string" }, "to_lang": { "type": "string" } }, "required": ["text", "to_lang"] }, "outputs": { "type": "object", "properties": { "translated_text": { "type": "string" } } }, "provider": { "name": "translation_service", "provider_type": "graphql", "url": "https://api.translate.com/graphql", "operation_type": "mutation", "operation_name": "Translate" } } ] }
{ "name": "dev_tools", "provider_type": "text", "file_path": "~/dev/utcp/mock_tools.json", "watch_file": true, "encoding": "utf-8" }
© 2024 Universal Tool Calling Protocol. All rights reserved.